//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CColorRenderTarget10.h>
///	@path	~/src/graphics/dx10/
///	@date	2009/01/01
///	@desc	.

#pragma once

#include "xeres.h"

#include "graphics/dx10/CDevice10.h"
#include "graphics/ITexture.h"
#include "graphics/IRenderTarget.h"

namespace xeres {
	
	/*! 
		\class	CColorRenderTarget10
		\brief
	*/
	class CColorRenderTarget10 : public IRenderTarget
	{
	public:

		/// \ctor
		CColorRenderTarget10( ID3D10Texture2D * tex , ID3D10RenderTargetView * renderTarget , ID3D10ShaderResourceView * shaderView );

		/// \dtor
		virtual ~CColorRenderTarget10( void );

		DECL_IOBJECT_CLASS( CColorRenderTarget10 , IRenderTarget );

	public:

		/// \name Render target interface.
		//@{

		/// \impl
		virtual bool OnLostDevice( void );

		/// \impl
		virtual bool OnResetDevice( RefWeak<IDevice> device );

		/// \impl
		virtual TextureType GetType( void );

		/// \impl
		virtual DXFormat GetFormat( void );

		/// \impl
		virtual Pair<int> GetSize( void );

		/// \impl
		virtual size_t GetDepth( void );

		/// \impl
		virtual bool IsWritable( void );

		/// \impl
		virtual bool IsReadable( void );

		/// \impl
		virtual bool Map( uint sub , ResourceMap& data );

		/// \impl
		virtual bool ReadBack( uint sub , ResourceMap& data , bool readonly );

		/// \impl
		virtual bool Unmap( uint sub );

		/// \impl
		virtual bool Update( uint sub , const Box<uint>& size , const byte * data , uint row_pitch , uint depth_pitch );

		/// \impl
		virtual bool ApplyTarget( RefWeak<IDevice> device );

		/// \impl
		virtual IUnknown * GetTextureInterface( void );

		/// \impl
		virtual IUnknown * GetRenderTargetInterface( void );

		//@}

	private:

		// @data
		ID3D10Texture2D *				m_pTexture;
		ID3D10RenderTargetView *		m_pRtView;
		ID3D10ShaderResourceView *		m_pShaderView;
		D3D10_TEXTURE2D_DESC			m_texDesc;
		D3D10_RENDER_TARGET_VIEW_DESC	m_rtDesc;
		D3D10_SHADER_RESOURCE_VIEW_DESC m_shaderDesc;
	};

} // namespace xeres
